﻿namespace instamuz.DataAccess.Queries.AccountQueries
{
    using System.Linq;
    using Domain.Entities;
    using IndyCode.Infrastructure.Domain;
    using IndyCode.Infrastructure.NHibernate;
    using instamuz.Application.Criterias.Account;

    public class FindAccountByLoginQuery : LinqQueryBase<Account, FindAccountByLoginCriteria, Account>
    {
        public FindAccountByLoginQuery(ILinqProvider linq) : base(linq)
        {
        }

        public override Account Ask(FindAccountByLoginCriteria criterion)
        {
            var login = criterion.Login.ToLower();

            return Query
                .SingleOrDefault(x => x.Login.ToLower() == login);
        }
    }
}